package handlers

import (
	"MBTIx/dba"
	"MBTIx/models"
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/jmoiron/sqlx"
)

func Get_problem(c *gin.Context) {
	db, _ := c.Get("db")
	var problem models.Problem
	var pro_id models.Id
	c.ShouldBind(&pro_id)
	dba.SelectProByProId(db.(*sqlx.DB), pro_id.Pro_id, &problem)
	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"data": problem,
	})
}
func Get_pro(c *gin.Context) {
	db, _ := c.Get("db")

	var problems []models.Problem
	dba.SelectAllPro(db.(*sqlx.DB), &problems)

	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"data": gin.H{
			"pro": problems,
		},
	})
}
